<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://d3js.org/d3.v5.js"></script>
</head>
<body>
  <p>Vue</p>
  <p>React</p>
  <p>Angular</p>
  <button id="datum">datum</button>
  <button id="data">data</button>
  <script>
  const oDatum = document.querySelector('#datum')
  const oData = document.querySelector('#data')
  const body = d3.select('body')
  const p = body.selectAll('p')
  oDatum.onclick = function() {
    const str = 'Framework'
    p.datum(str)
    p.text(function(d, i) {
      return `${d}-${i}`
    })
  }
  oData.onclick = function() {
    const dataset = ['Vue', 'React', 'Angular']
    p.data(dataset).text(function(d, i) {
      return `${d}-${i}`
    })
  }
  </script> 
</body>
</html>